import pandas as pd

# 读取数据
data = pd.read_csv('京东商品评价.csv')

# 创建一个函数来打标签
def label_sentiment(row):
    if row in [4, 5]:
        return '好评'
    elif row in [2, 3]:
        return '中评'
    elif row == 1:
        return '差评'
    else:
        return '未知'

# 给“评价等级”列打上标签
data['评价类型'] = data['评价等级'].apply(label_sentiment)

# 导出数据
data.to_csv('京东商品评价_打标签.csv', index=False, encoding='utf-8-sig')
